package exam2;

public class PCBThread {

    private String name;
    private int id;
    private int next;
    private int needTime;
    private int runTime;
    private int CPUTime;
    private boolean state;

    public PCBThread(String name, int id, int next, int needTime) {
        this.name = name;
        this.id = id;
        this.next = next;
        this.needTime = needTime;
        this.runTime = 0;
        this.CPUTime = 0;
        this.state = false;
    }

    public void runOnce() {
        if (this.runTime < this.needTime) {
            this.runTime++;
        }

    }

    public boolean isEnd() {
        if (this.state) {
            return true;
        } else if (this.runTime == this.needTime) {
            this.state = true;
            return true;
        }
        return false;
    }

    public String getName() {
        return name;
    }

    public int getId() {
        return id;
    }

    public int getNext() {
        return next;
    }

    public int getNeedTime() {
        return needTime;
    }

    public int getRunTime() {
        return runTime;
    }

    public int getCPUTime() {
        return CPUTime;
    }

    public void setCPUTime(int CPUTime) {
        this.CPUTime = CPUTime;
    }
}
